###
# 
# Copyright (c) MASC.
# All rights reserved.
#
# Author: ShenYongchen (shenyczz@163.com)
# 
###############################################################################
# Root
# 
# 版本
cmake_minimum_required(VERSION 3.8...3.12 FATAL_ERROR)

# 策略
foreach(policy CMP0068 CMP0071 CMP0083)
  if(POLICY ${policy})
    cmake_policy(SET ${policy} NEW)
  endif()
endforeach()

# 项目
project(CLAPACK)

# 测试
include(CTest)
enable_testing()

# 打包
# set(CPACK_PROJECT_NAME ${PROJECT_NAME})
# set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
# include(CPack)

#------------------------------------------------------------------------------
# 设置 cmake 目录
set(_my_cmake_dir_ "${CMAKE_CURRENT_LIST_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${_my_cmake_dir_}")

# SFX 宏消息开关
set(SFX_MACRO_MESSAGE_SWITCH OFF)

# 按照以下顺序引入 cmake 文件
include(sfxASystem)
include(sfxVersion)
include(sfxOptions)
include(sfxDirectory)
include(sfxMacros)
include(sfxCompilerChecks)
include(sfxCompilerPlatformFlags)
include(sfxFunctions)


#------------------------------------------------------------------------------
# 选项
option(BUILD_SHARED_LIBS "Build shared library." ON)


#------------------------------------------------------------------------------
# 链接库目录
# link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})

#------------------------------------------------------------------------------
# 
if(WIN32 AND NOT CYGWIN)
  add_definitions(-DNO_ISATTY -DMSDOS -DUSE_CLOCK)
  set(SECOND_SRC  ${CLAPACK_SOURCE_DIR}/INSTALL/winsecond.c)
  set(DSECOND_SRC  ${CLAPACK_SOURCE_DIR}/INSTALL/windsecnd.c)
else()
  set(SECOND_SRC  ${CLAPACK_SOURCE_DIR}/INSTALL/second.c)
  set(DSECOND_SRC  ${CLAPACK_SOURCE_DIR}/INSTALL/dsecnd.c)
endif()

option(USE_BLAS_WRAP "pre-pend f2c_ to each function in blas" OFF)
if(NOT USE_BLAS_WRAP)
  add_definitions(-DNO_BLAS_WRAP) # _zrotg_ seems to be missing in the wrap header
endif()

#------------------------------------------------------------------------------
add_subdirectory(F2CLIBS)
add_subdirectory(LAPACK)
add_subdirectory(Examples)
# add_subdirectory("UnitTesting")

